#ifndef YJUI_H
#define YJUI_H

#include "YJWidgetFactory.h"
#include "YJOptionalWidgetFactory.h"
#include "YJApplication.h"
#include "binder.h"

#include <YEvent.h>
#include <YUI.h>

class YJUI: public YUI {
public:
	YJUI(int id, bool with_threads);
	void checkInit(); // called 1st time when execution thread kicks in

	static YJUI *ui() {
		return (YJUI *) YUI::ui();
	}

	static YJUI *createUI(bool withThreads);

protected:
	virtual YJWidgetFactory * createWidgetFactory();
	virtual YJOptionalWidgetFactory *createOptionalWidgetFactory();
	virtual YJApplication *createApplication();

public:
	virtual YEvent* runPkgSelection(YWidget*);
	virtual void idleLoop(int);



	static void set_widget_factory(constructor_callback c) {
		create_widget_factory_cb = c;
	}
	static void set_optional_widget_factory(constructor_callback c) {
		create_optional_widget_factory_cb = c;
	}
	static void set_application(constructor_callback c) {
		create_application_cb = c;
	}
	static void set_constructor_callback(top_constructor_callback c){
		constructor_cb=c;
	}

	static int test();

private:
	static constructor_callback create_widget_factory_cb;
	static constructor_callback create_optional_widget_factory_cb;
	static constructor_callback create_application_cb;
	static top_constructor_callback constructor_cb;

	int classId;
};


#endif /*YJUI_H*/
